package com.zbkj.crmeb.user.service.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.zbkj.crmeb.chant.service.ChannelMemberLevelService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.CommonPage;
import com.constants.Constants;
import com.crmeb.core.exception.CrmebException;
import com.factory.CommonFactory;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.utils.CrmebUtil;
import com.utils.DateUtil;
import com.utils.vo.dateLimitUtilVo;
import com.zbkj.crmeb.chant.model.ChannelMemberLevel;
import com.zbkj.crmeb.chant.model.ChannelMerchant;
import com.zbkj.crmeb.chant.model.ChannelMerchantAccount;
import com.zbkj.crmeb.chant.service.IChannelMerchantAccountService;
import com.zbkj.crmeb.chant.service.IChannelMerchantService;
import com.zbkj.crmeb.enums.AccountFlowTypeEnum;
import com.zbkj.crmeb.enums.AreaTypeEnum;
import com.zbkj.crmeb.enums.OrderTradeTypeEnum;
import com.zbkj.crmeb.enums.StockAreaTempEnum;
import com.zbkj.crmeb.member.model.ChannelMerchantAttribute;
import com.zbkj.crmeb.member.model.MerchantMemberBenefits;
import com.zbkj.crmeb.member.model.MerchantMemberType;
import com.zbkj.crmeb.member.service.IChannelMerchantAttributeService;
import com.zbkj.crmeb.member.service.IMerchantMemberBenefitsService;
import com.zbkj.crmeb.member.service.IMerchantMemberTypeService;
import com.zbkj.crmeb.merchant.api.request.BuyMemberRequest;
import com.zbkj.crmeb.merchant.api.response.InformationMemberResponse;
import com.zbkj.crmeb.merchant.api.response.MemberDetailsResponse;
import com.zbkj.crmeb.merchant.api.response.ShowMemberResponse;
import com.zbkj.crmeb.order.oprocess.IOrderProcess;
import com.zbkj.crmeb.store.model.StoreAccountInfo;
import com.zbkj.crmeb.store.request.UserMemberRecordFeature;
import com.zbkj.crmeb.store.service.AccountFlowService;
import com.zbkj.crmeb.store.service.StoreAccountInfoService;
import com.zbkj.crmeb.store.utilService.OrderUtils;
import com.zbkj.crmeb.user.dao.UserMemberRecordDao;
import com.zbkj.crmeb.user.model.User;
import com.zbkj.crmeb.user.model.UserMemberLevelRecord;
import com.zbkj.crmeb.user.model.UserMemberRecord;
import com.zbkj.crmeb.user.request.MemberRecordRequest;
import com.zbkj.crmeb.user.response.MemberRecordInfoResponse;
import com.zbkj.crmeb.user.response.MemberRecordResponse;
import com.zbkj.crmeb.user.service.UserMemberRecordService;
import com.zbkj.crmeb.user.service.UserService;

import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 * 用户购买会员记录表 服务实现类
 * </p>
 *
 * @author wuzp
 * @since 2022-05-11
 */
@Service
@Slf4j
public class UserMemberRecordServiceImpl extends ServiceImpl<UserMemberRecordDao, UserMemberRecord> implements UserMemberRecordService {

    @Autowired
    private UserMemberRecordDao userMemberRecordDao;
    @Autowired
    private CommonFactory commonFactory;
    @Autowired
    private IMerchantMemberTypeService merchantMemberTypeService;
    @Autowired
    private OrderUtils orderUtils;
    @Autowired
    private IChannelMerchantAccountService channelMerchantAccountService;
    @Autowired
    private AccountFlowService accountFlowService;
    @Autowired
    private UserService userService;
    @Autowired
    private IChannelMerchantService channelMerchantService;
    @Autowired
    private IMerchantMemberBenefitsService merchantMemberBenefitsService;
    @Autowired
    private StoreAccountInfoService storeAccountInfoService;
    @Autowired
    private IChannelMerchantAttributeService channelMerchantAttributeService;
    @Autowired
    private ChannelMemberLevelService channelMemberLevelService;

    @Value("${order.yueMerIds}")
    private List<Integer> yueMerIds;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Object buyMember(BuyMemberRequest request) {
        if(yueMerIds.contains(request.getMerId()) && Constants.PAY_TYPE_YUE.equals(request.getPayType())) {
            throw new CrmebException("该商户余额支付功能已关闭");
        }

        // 获取支付渠道
        Integer type = orderUtils.getOrderPayType(request.getMerId()).getCode();
        //计算支付金额，及是否能够购买
        MerchantMemberType memberType = merchantMemberTypeService.getById(request.getMemberTypeId());
        if(null == memberType || memberType.getDeleteFlag() || !memberType.getEnableFlag() ){
            throw new CrmebException("该会员类型不存在");
        }
        if(memberType.getSpecialPrice().compareTo(request.getPrice()) != 0){
            throw new CrmebException("支付金额异常");
        }
        User user = userService.getInfo();
        request.setUid(user.getUid());
        // 扫码支付原样输出
        if(!Constants.PAY_TYPE_WE_CHAT_FROM_NATIVE.equals(request.getFromType())) {
        	request.setFromType(Constants.PAY_TYPE_WE_CHAT_FROM_PROGRAM);
        }
        request.setMemberType(memberType.getMemberType());
        request.setEffectiveTime(memberType.getEffectiveTime());
        //订单号
        request.setOrderNo(CrmebUtil.getOrderNo(Constants.PAY_TYPE_WE_CHAT));
        IOrderProcess process = commonFactory.getOrderType(type);
        createMemberRecord(request);
        return process.buyMember(request);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Object buyMemberRecord(BuyMemberRequest request) {
        if(yueMerIds.contains(request.getMerId()) && Constants.PAY_TYPE_YUE.equals(request.getPayType())) {
            throw new CrmebException("该商户余额支付功能已关闭");
        }

        // 获取支付渠道
        Integer type = orderUtils.getOrderPayType(request.getMerId()).getCode();
        //计算支付金额，及是否能够购买
        MerchantMemberType memberType = merchantMemberTypeService.getById(request.getMemberTypeId());
        if(null == memberType || memberType.getDeleteFlag() || !memberType.getEnableFlag() ){
            throw new CrmebException("该会员类型不存在");
        }
        if(memberType.getSpecialPrice().compareTo(request.getPrice()) != 0){
            throw new CrmebException("支付金额异常");
        }
        User user = userService.getInfo();
        request.setUid(user.getUid());
        // 扫码支付原样输出
        if(!Constants.PAY_TYPE_WE_CHAT_FROM_NATIVE.equals(request.getFromType())) {
            request.setFromType(Constants.PAY_TYPE_WE_CHAT_FROM_PROGRAM);
        }
        request.setMemberType(memberType.getMemberType());
        request.setEffectiveTime(memberType.getEffectiveTime());
        //订单号
        request.setOrderNo(CrmebUtil.getOrderNo(Constants.PAY_TYPE_WE_CHAT));
        IOrderProcess process = commonFactory.getOrderType(type);

        // 更新当前用户信息
        boolean isUpdateUser = updateUser(request);
        if(!isUpdateUser){
            throw new CrmebException("当前用户信息更新异常");
        }
        // 保存会员信息
        createMemberRecord(request);
        return process.buyMember(request);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer saveMemberRecord(BuyMemberRequest request) {
        // 校验必填项
        checkUser(request);

        User user = userService.getInfo();
        request.setUid(user.getUid());
        // 更新当前用户信息
        boolean isUpdateUser = updateUser(request);
        if(!isUpdateUser){
            throw new CrmebException("当前用户信息更新异常");
        }
        // 保存会员信息
        Integer recordId = createUserMemberRecord(request);
        return recordId;
    }

    /**
     * 校验必填项
     */
    private void checkUser(BuyMemberRequest request) {

        if(StringUtils.isBlank(request.getRealName())){
            throw new CrmebException("姓名不能为空！");
        }
        if(StringUtils.isBlank(request.getCardId())){
            throw new CrmebException("身份证号不能为空！");
        }
        if(StringUtils.isBlank(request.getPhone())){
            throw new CrmebException("手机号不能为空！");
        }
        if(request.getSex() == 0){
            throw new CrmebException("请选择性别！");
        }
        if(StringUtils.isBlank(request.getBirthday())){
            throw new CrmebException("出生年月不能为空！");
        }
        if(StringUtils.isBlank(request.getEmail())){
            throw new CrmebException("电子邮箱不能为空！");
        }
        if(StringUtils.isBlank(request.getAddres())){
            throw new CrmebException("通讯地址不能为空！");
        }

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveQuestionnaire(BuyMemberRequest request) {

        User user = userService.getInfo();
        request.setUid(user.getUid());
//        // 更新当前用户信息
//        boolean isUpdateUser = updateUser(request);
//        if(!isUpdateUser){
//            throw new CrmebException("当前用户信息更新异常");
//        }
        // 更新问卷调查
        updateQuestionnaire(request);
        return true;
    }

    /**
     * 更新当前用户信息
     * @param request
     */
    private boolean updateUser(BuyMemberRequest request) {
        User user = new User();
        BeanUtils.copyProperties(request,user);
        return userService.updateForBuyMember(user);
    }

    private Integer createUserMemberRecord(BuyMemberRequest request) {
        //生成记录
        UserMemberRecord userMemberRecord = new UserMemberRecord();
        BeanUtils.copyProperties(request,userMemberRecord);
        userMemberRecord.setEffectiveDays(Constants.NUM_ZERO);
        userMemberRecord.setMemberType(3);
        userMemberRecord.setPayPrice(BigDecimal.ZERO);
        userMemberRecord.setPaid(2);
        userMemberRecord.setPayTime(new Date());
        userMemberRecord.setEffectTime(new Date());
        userMemberRecord.setExpirationTime(new Date());
        this.save(userMemberRecord);
        return userMemberRecord.getId();
    }

    private boolean updateQuestionnaire(BuyMemberRequest request) {
        LambdaUpdateWrapper<UserMemberRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        if(null == request.getRecordId())
            throw new CrmebException("会员记录id为空");

        UserMemberRecord existUserMember = this.getById(request.getRecordId());

        if (Objects.isNull(existUserMember)){
            throw new CrmebException("会员记录不存在");
        }
        UserMemberRecordFeature userMemberRecordFeature = new UserMemberRecordFeature();
        BeanUtils.copyProperties(request,userMemberRecordFeature);
        String featureStr = JSONObject.toJSONString(userMemberRecordFeature);
        if(StringUtils.isEmpty(featureStr)){
            return false;
        }

        lambdaUpdateWrapper.eq(UserMemberRecord::getId,existUserMember.getId());
        lambdaUpdateWrapper.set(UserMemberRecord::getFeature, featureStr);

        return update(lambdaUpdateWrapper);
    }

    private void createMemberRecord(BuyMemberRequest request) {
        //生成记录
        UserMemberRecord userMemberRecord = new UserMemberRecord();
        BeanUtils.copyProperties(request,userMemberRecord);
        userMemberRecord.setEffectiveDays(request.getEffectiveTime());
        userMemberRecord.setPayPrice(request.getPrice());
        userMemberRecord.setPaid(0);
        userMemberRecord.setPayTime(new Date());
        userMemberRecord.setEffectTime(new Date());
        userMemberRecord.setExpirationTime(new Date());
        this.save(userMemberRecord);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean successfulAfter(String orderNo, Integer uid, String outOrderId) {
        //支付成功后逻辑
        UserMemberRecord record = this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getOrderNo, orderNo));
        if(record == null || record.getPaid() == 1){
            log.error("支付回调异常，订单id:{}",orderNo);
            return false;
        }
        record.setPaid(1);
        record.setOutOrderId(outOrderId);
        //支付时间
        record.setPayTime(new Date());
        //查询未过期的上一条记录
        UserMemberRecord lastRecord = this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getUid, record.getUid()).eq(UserMemberRecord::getPaid,1)
                .gt(UserMemberRecord::getExpirationTime, new Date()).orderByDesc(UserMemberRecord::getExpirationTime).last("LIMIT 1"));
        //生效时间
        record.setEffectTime(null != lastRecord ? DateUtil.addSecond(lastRecord.getExpirationTime(),1) : new Date());
        //过期时间
        record.setExpirationTime(DateUtil.addDay(record.getEffectTime(),record.getEffectiveDays()));
        this.updateById(record);
        //新增账户明细表
        addAccountInfo(record.getUid(), record);
        //null余额支付  true平台支付   false商家支付/线下支付
        Boolean payType = orderUtils.getPayType(record.getPayType());
        ChannelMerchantAccount merchantAccount = new ChannelMerchantAccount();
        merchantAccount.setMerId(record.getMerId())
                .setTotalMoney(record.getPayPrice());
        if(payType == null){
            //余额支付 余额+0
            merchantAccount.setAccount(BigDecimal.ZERO);
            channelMerchantAccountService.calcMoney(merchantAccount);
            //记录商户流水操作
            accountFlowService.saveAccountFlow(record.getMerId(),record.getId(),record.getUid(),null,
                    AccountFlowTypeEnum.MEMBER,BigDecimal.ZERO,null,null,"购买会员");
        }else if(payType) {
            //平台支付 + 用户购买会员金额直接累加的商户的可用余额
            merchantAccount.setAccount(record.getPayPrice());
            channelMerchantAccountService.calcMoney(merchantAccount);
            //记录商户流水操作
            accountFlowService.saveAccountFlow(record.getMerId(),record.getId(),record.getUid(),null,
                    AccountFlowTypeEnum.MEMBER,record.getPayPrice(),null,null,"购买会员");
        }else {
            //商家支付  + 购买会员金额直接到商户微信收款金额中
            merchantAccount.setWithdrawAccount(record.getPayPrice());
            channelMerchantAccountService.calcMoney(merchantAccount);
            //记录商户流水操作
            accountFlowService.saveAccountFlow(record.getMerId(),record.getId(),record.getUid(),null,
                    AccountFlowTypeEnum.MEMBER,null,record.getPayPrice(),null,"购买会员");
        }
        //查询是否有立即到账的优惠券
        merchantMemberBenefitsService.automaticallyIssueCoupons(uid);
        return true;
    }

    private void addAccountInfo(Integer uid, UserMemberRecord record) {
        User user = userService.getById(uid);
        StoreAccountInfo info = new StoreAccountInfo();
        info.setOrderId(record.getOrderNo());
        info.setUid(uid);
        info.setOutOrderId(record.getOutOrderId());
        info.setRealName(user.getNickname());
        info.setNowMoney(user.getNowMoney());
        info.setTradeType(OrderTradeTypeEnum.CONSUME.getType());
        info.setTradePrice(record.getPayPrice());
        info.setPayType(record.getPayType());
        if(Constants.PAY_TYPE_YUE.equals(record.getPayType())){
            info.setIsAccount(1);
        }
        info.setRemark("消费"+ record.getPayPrice()+"购买会员");
        storeAccountInfoService.save(info);
    }

    @Override
    public boolean yuePayMember(BuyMemberRequest request) {
        User user = userService.getInfo();
        //判断账户余额是否足够
        if(user.getNowMoney().compareTo(request.getPrice()) < 0){
            throw new CrmebException("余额不足");
        }
        //余额支付操作
        BigDecimal priceSubtract = user.getNowMoney().subtract(request.getPrice());
        boolean updateUserResult = userService.updateNowMoney(user.getUid(), priceSubtract);
        if (!updateUserResult) {
            throw new CrmebException("支付失败");
        }
        //支付成功后操作
        return this.successfulAfter(request.getOrderNo(),request.getUid(),"");
    }

    @Override
    public UserMemberRecord getByOrderNo(String orderNo) {
        return this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getOrderNo, orderNo));
    }

    @Override
    public PageInfo<MemberRecordResponse> getMerMemberList(MemberRecordRequest request, Integer merId) {
        request.setMerId(merId);
        if(StringUtils.isNotBlank(request.getDateLimit())){
            dateLimitUtilVo dateLimitUtilVo = DateUtil.getDateLimit(request.getDateLimit());
            request.setStartTime(dateLimitUtilVo.getStartTime());
            request.setEndTime(dateLimitUtilVo.getEndTime());
        }
        Page<Object> page = PageHelper.startPage(request.getPage(), request.getLimit());
        List<MemberRecordResponse> list = userMemberRecordDao.getMerMemberList(request);
        return CommonPage.copyPageInfo(page,list);
    }

    @Override
    public ShowMemberResponse showMember(Integer merId) {
        ShowMemberResponse response = new ShowMemberResponse();
//        ChannelMerchant channelMerchant = channelMerchantService.getChannelMerchantByMerId(merId);
        ChannelMerchant channelMerchant = channelMerchantService.getById(merId);
        BeanUtils.copyProperties(channelMerchant,response);
        return response;
    }

    @Override
    public InformationMemberResponse informationMember() {
        InformationMemberResponse response = new InformationMemberResponse();
        User user = userService.getInfo();
        BeanUtils.copyProperties(user, response);
        if(user != null){
            UserMemberRecord record = this.getUserMember(user.getUid());
            if(record != null){
                UserMemberRecord lastRecord = this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getUid, user.getUid()).eq(UserMemberRecord::getPaid, 1)
                        .orderByDesc(UserMemberRecord::getExpirationTime).last("LIMIT 1"));
                response.setMemberType(record.getMemberType());
                response.setExpirationTime(record.getExpirationTime());
            }else{
                UserMemberRecord lastRecord = this.lambdaQuery()
                        .eq(UserMemberRecord::getUid, user.getUid())
                        .eq(UserMemberRecord::getPaid, 2)
                        .orderByDesc(UserMemberRecord::getCreateTime)
                        .last("LIMIT 1").one();
                if(lastRecord != null) {
                    response.setRecordId(lastRecord.getId());
                    response.setMemberType(lastRecord.getMemberType());
                    String levelName = channelMemberLevelService.lambdaQuery().eq(ChannelMemberLevel::getLevel, user.getLevel())
                            .eq(ChannelMemberLevel::getMerId, user.getMerId()).one().getName();
                    response.setLevelName(levelName);
                    String featureStr = lastRecord.getFeature();
                    if (StringUtils.isEmpty(featureStr)) {
                        // 获取问卷调查数据
                        UserMemberRecord questionnaire = this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getUid, user.getUid())
                                .isNotNull(UserMemberRecord::getFeature)
                                .orderByDesc(UserMemberRecord::getExpirationTime)
                                .last("LIMIT 1"));
                        if (null != questionnaire) {
                            featureStr = questionnaire.getFeature();
                        }
                    }
                    if (StringUtils.isEmpty(featureStr)) {
                        return response;
                    }
                    UserMemberRecordFeature recordFeature = JSONObject.parseObject(featureStr, UserMemberRecordFeature.class);
                    response.setPreferType(recordFeature.getPreferType());
                    response.setPreferPlace(recordFeature.getPreferPlace());
                    response.setAcceptablePrice(recordFeature.getAcceptablePrice());
                    response.setWineUsage(recordFeature.getWineUsage());
                    response.setPurchaseChannel(recordFeature.getPurchaseChannel());
                    response.setWineBuyTimes(recordFeature.getWineBuyTimes());
                    response.setWineTastingEvent(recordFeature.getWineTastingEvent());
                    response.setWishWineTastingEvent(recordFeature.getWishWineTastingEvent());
                    response.setAdvise(recordFeature.getAdvise());
                }
            }
        }
        return response;
    }

    @Override
    public UserMemberRecord getUserMember(Integer uid) {
        return this.getOne(Wrappers.<UserMemberRecord>lambdaQuery().eq(UserMemberRecord::getUid, uid).eq(UserMemberRecord::getPaid, 1)
                .apply("curtime() BETWEEN effect_time AND expiration_time"));
    }

    @Override
    public MemberDetailsResponse getMemberDetails(Integer merId) {
        MemberDetailsResponse memberDetailsResponse = new MemberDetailsResponse();
        List<MerchantMemberBenefits> memberBenefitsList = merchantMemberBenefitsService.list(Wrappers.lambdaQuery(MerchantMemberBenefits.class)
                .eq(MerchantMemberBenefits::getMerId,merId).eq(MerchantMemberBenefits::getEquityEnableFlag,true));
        memberDetailsResponse.setMemberBenefitsList(memberBenefitsList);

        List<MerchantMemberType> memberTypeList = merchantMemberTypeService.list(Wrappers.lambdaQuery(MerchantMemberType.class)
                .eq(MerchantMemberType::getMerId,merId)
                .eq(MerchantMemberType::getDeleteFlag,false)
                .eq(MerchantMemberType::getEnableFlag,true)
                .orderByDesc(MerchantMemberType::getSort));
        memberDetailsResponse.setMemberTypeList(memberTypeList);
        ChannelMerchantAttribute channelMerchantAttribute = channelMerchantAttributeService.getOne(Wrappers.lambdaQuery(ChannelMerchantAttribute.class).eq(ChannelMerchantAttribute::getMerId,merId));
        memberDetailsResponse.setMembershipAgreement(channelMerchantAttribute.getMembershipAgreement());
        return memberDetailsResponse;
    }

    @Override
    public MemberRecordInfoResponse getMemberInfoById(Integer id) {
        UserMemberRecord record = this.getById(id);
        if(record == null){
            throw new CrmebException("该订单不存在");
        }
        MemberRecordInfoResponse response = new MemberRecordInfoResponse();
        ChannelMerchant channelMerchant = channelMerchantService.getChannelMerchantByMerId(record.getMerId());
        User user = userService.getById(record.getUid());
        response.setMerId(channelMerchant.getId());
        response.setMerName(channelMerchant.getChannelName());
        response.setPayPrice(record.getPayPrice());
        response.setPayTime(record.getPayTime());
        response.setPayType(getPayType(record.getPayType()));
        response.setOrderId(record.getOutOrderId());
        response.setUAvatar(user.getAvatar());
        response.setNickName(user.getNickname());
        response.setUserPhone(user.getPhone());
        return response;
    }

    private String getPayType(String payType) {
        switch (payType){
            case Constants.PAY_TYPE_WE_CHAT:
                return Constants.PAY_TYPE_STR_WE_CHAT;
            case Constants.PAY_TYPE_WE_CHAT_NATIVE:
            	return Constants.PAY_TYPE_STR_WE_CHAT_NATIVE;
            case Constants.PAY_TYPE_YUE:
                return Constants.PAY_TYPE_STR_YUE;
            case Constants.PAY_TYPE_OFFLINE:
                return Constants.PAY_TYPE_STR_OFFLINE;
            case Constants.PAY_TYPE_ALI_PAY:
                return Constants.PAY_TYPE_STR_ALI_PAY;
            case Constants.PAY_TYPE_TMALL_PAY:
                return Constants.PAY_TYPE_STR_TMALL_PAY;
            case Constants.PAY_TYPE_HK_PAY:
                return Constants.PAY_TYPE_STR_HK_PAY;
            case Constants.PAY_TYPE_ORAGE_PAY:
                return Constants.PAY_TYPE_STR_ORAGE_PAY;
            case Constants.PAY_TYPE_ADAPAY_DEGREE:
            	return Constants.PAY_TYPE_STR_ADAPAY_DEGREE;
            case Constants.PAY_TYPE_ADAPAY_CN:
            	return Constants.PAY_TYPE_STR_ADAPAY_CN;
            default:
                return Constants.PAY_TYPE_STR_OTHER;
        }
    }

}
